﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
namespace GaiNo.Core.Helpers
{
    public static class SessionHelper
    {
        public static T Get<T>(string key)
        {
            if (HttpContext.Current.Session[key] == null)
                return default(T);
            return (T)HttpContext.Current.Session[key];
        }
        public static void Set(string key, object value)
        {
            if (HttpContext.Current.Session[key] == null)
                HttpContext.Current.Session.Add(key, value);
            else
                HttpContext.Current.Session[key] = value;
        }
        public static void Clear()
        {
            HttpContext.Current.Session.Clear();
        }
        public static void Remove(string key)
        {
            if (HttpContext.Current.Session[key] != null)
                HttpContext.Current.Session.Remove(key);
        }
    }
}
